package my.service;

import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.ActiveRecordException;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import my.model.Post;

/**
 * Created by Administrator on 2017/6/15.
 */
public class PostService {
    public Log log = Log.getLog(PostService.class);

    public boolean save(Post post) {
        boolean success = false;
        try {
            post.save();
            success = true;
        } catch (ActiveRecordException e) {
            log.error("日志保存失败:" + e.getMessage());
        }
        return success;

    }

    public Record getPostById(int id) {
        return Db.findFirst("SELECT * FROM post_detail_view WHERE id = ?", id);
    }
}
